<%@ page import="java.util.List" %>
<%@ page import="com.etime.entity.Student" %>
<%@ page import="com.etime.service.impl.StudentServiceImpl" %>
<%@ page import="com.etime.servlet.StudentServlet" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2023/3/14
  Time: 12:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>学生表</title>
</head>
<body>
<form action="showServlet" method="get">
  <input type="hidden" name="flag" value="select">
  账号：<input type="text" name="name">
  密码：<input type="password" name="password">
  <input type="submit" value="查询">
</form><br>
<form action="studentServlet" method="post" enctype="multipart/form-data">
  <input type="hidden" name="flag" value="insert">
  账号：<input type="text" name="name">
  密码：<input type="password" name="password">
  图片：<input type="file" name="photo">
  <input type="submit" value="添加">
</form><br>
<table border="1" cellspacing="0" cellpadding="0" width="500">
  <tr>
    <th>ID</th>
    <th>姓名</th>
    <th>密码</th>
    <th width="50">照片</th>
    <th>操作</th>
  </tr>
  <%
    List<Student> list = (List<Student>)request.getAttribute("list");
    for (Student i : list){
      session.setAttribute("sid",i.getId());
  %>
  <tr>
    <td><%=i.getId()%></td>
    <td><%=i.getName()%></td>
    <td><%=i.getPassword()%></td>
    <td><img src="http://192.168.11.14:8080/photo/<%=i.getPhoto()%>" width="50"></td>
    <td>
      <a href="studentServlet?flag=delete&id=${sid}">删除</a>
      <button onclick="run(${sid})">修改</button>
    </td>
  </tr>
  <%
    }
  %>
</table>
<a href="showServlet?flag=limitSelect&page=1">首页</a>
${pageUtil.page}/${pageUtil.countPages}
<a href="showServlet?flag=limitSelect&page=${pageUtil.prevPage}">上一页</a>
<a href="showServlet?flag=limitSelect&page=${pageUtil.nextPage}">下一页</a>
<a href="showServlet?flag=limitSelect&page=${pageUtil.countPages}">末尾</a>
<form action="studentServlet" method="get" style="display:none" id="one">
  <input type="hidden" name="flag" value="update">
  <input type="hidden" name="sid" id="tow">
  请输入新的密码：<input type="text" name="password">
  <input type="submit" value="修改">
</form>
<script>
  function run(sid) {
    document.getElementById("one").style.display='block';
    document.getElementById("tow").value=sid;
  }
</script>
</body>
</html>
